#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2021/4/21 16:42
# @Author  : LiShan
# @Email   : lishan_1997@126.com
# @File    : Gym-Test.py
# @Note    : this is note

import gym
envs = gym.envs.registry.all()
for i in envs:
    print(i)


# import gym
# env = gym.make('Pong-v0')
# env.reset()
# for _ in range(1000):
#     env.render()
#     env.step(env.action_space.sample())
# env.close()


# 官方例程 CartPole-v0
import gym
env = gym.make('CartPole-v0')
for i_episode in range(20):
    env.reset()
    for t in range(100):
        env.render()
        action = env.action_space.sample()
        observation, reward, done, info = env.step(action)
        print(observation)
        if done:
            print("Episode finished after {} timesteps".format(t+1))
            break
env.close()
